﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="exemplo_Ajax.aspx.cs" Inherits="WebApplication1.Exemplo_Ajax" %>

<%@ Register Assembly="Libero.FusionCharts" Namespace="Libero.FusionCharts.Control"
    TagPrefix="fcl" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <style type="text/css">
        body
        {
            font-family: Calibri, Arial, Tahoma;
        }
        .style1
        {
            color: black;
        }
        .style2
        {
            color: #800000;
        }
        .style3
        {
            color: blue;
        }
    </style>
<script src="js/jquery-1.4.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
    loadChart = function () {
        var period          = $("#period option:selected").val();
        var chartType       = $("#chartType option:selected").val();
        var chartTemplate   = $("#chartTemplate option:selected").val();

        $.ajax({
            url: "exemplo_Ajax.aspx?chartType=" + chartType + "&chartTemplate=" + chartTemplate + "&period=" + period,
            type: "POST",
            dataType: "text",
            success: function (data) {
                var oChart = <%=chtSales.ClientID %>;
                oChart.xmlData   = data;
                oChart.chartType = chartType;
                oChart.showChart();
            }
        });
    }
</script>
</head>
<body runat="server">
    <form id="form1" runat="server">
    <div>
        <h3>Ajax sample.</h3>
        <hr />
        &nbsp;&nbsp;&nbsp;&nbsp;
        &nbsp;&nbsp;&nbsp;&nbsp;
        Period:
        <select id="period" onchange="loadChart()">
            <option value="2010">2010</option>
            <option value="2009">2009</option>
            <option value="2008">2008</option>
        </select>
        &nbsp;&nbsp;&nbsp;&nbsp;
        Type:
        <select id="chartType" onchange="loadChart()">
            <option value="Area2DChart">Area 2D Chart</option>
            <option value="Bar2DChart">Bar 2D Chart</option>
            <option value="Column2DChart">Column 2D Chart</option>
            <option value="Column3DChart">Column 3D Chart</option>
            <option value="LineChart">Line Chart</option>
        </select>
        &nbsp;&nbsp;&nbsp;&nbsp; 
        Template:
        <select id="chartTemplate" onchange="loadChart()">
            <option value="OfficeTemplate">Office</option>
            <option value="OfficeLightTemplate">Office Light</option>
            <option value="OfficeDarkTemplate">Office Dark</option>
            <option value="OceanTemplate">Ocean</option>
        </select>
        &nbsp;
        <hr />
        <fcl:FChart ID="chtSales" runat="server" Width="500" Height="320" />
        <hr />
        In this sample you have 3 sets of data by year. <br />
        In the drop down lists above you can choose which the period, chart type <br />
        and template you want to see.<br />
        The chart will be updated by Ajax when you change any value on the drop down lists.  <br />
        <br />
        In the ASPX file is set the FChart control, the drop down lists and the ajax* request.<br />
        <i>*using jQuery, course it is not mandatory.</i><br />
        <div>
        
            <pre style="font-family: consolas"><span style="color: blue">&lt;</span><span 
                style="color: maroon">script</span>&nbsp;<span style="color: red">src</span><span 
                style="color: blue">=&quot;js/jquery-1.4.1.min.js&quot;</span>&nbsp;<span 
                style="color: red">type</span><span style="color: blue">=&quot;text/javascript&quot;&gt;&lt;/</span><span 
                style="color: maroon">script</span><span style="color: blue">&gt;</span>
<span style="color: blue">&lt;</span><span style="color: maroon">script</span>&nbsp;<span 
                style="color: red">type</span><span class="style3">=&quot;text/javascript&quot;</span><span 
                style="color: blue">&gt;</span>
&nbsp;&nbsp;&nbsp;&nbsp;loadChart&nbsp;=&nbsp;func<span style="color: black">tion&nbsp;()&nbsp;</span>{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var&nbsp;peri<span style="color: black">od&nbsp;</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=&nbsp;$(&quot;<span 
                style="color: maroon">#period option:selected</span><span class="style1">&quot;).val();</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var&nbsp;chartTyp<span style="color: black">e&nbsp;&nbsp;</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=&nbsp;$(&quot;<span 
                style="color: maroon">#chartType option:selected</span><span class="style1">&quot;).val();</span><span 
                style="color: maroon">
&nbsp;&nbsp;</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var&nbsp;chartTemplat<span style="color: black">e&nbsp;&nbsp;</span>&nbsp;=&nbsp;$(&quot;<span 
                style="color: maroon">#chartTemplate option:selected</span><span 
                class="style1">&quot;).val();</span><span 
                style="color: maroon">
 
&nbsp;&nbsp;&nbsp;&nbsp;</span>&nbsp;&nbsp;&nbsp;&nbsp;$.ajax({
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;url:&nbsp;<span 
                class="style2">&quot;exemplo_Ajax.aspx?chart</span><span style="color: maroon">Type=&quot;&nbsp;+&nbsp;</span><span 
                class="style1">chartType</span><span style="color: maroon">&nbsp;+&nbsp;&quot;&amp;chartTe</span><span 
                class="style2">mplate=&quot;&nbsp;+&nbsp;</span><span class="style1">chartTemplate</span><span 
                class="style2">&nbsp;+&nbsp;&quot;&amp;period=&quot;</span>&nbsp;+&nbsp;period,
&nbsp;&nbsp;<span style="color: maroon">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>type:&nbsp;&quot;<span 
                class="style2">POST</span>&quot;,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dataTy<span 
                class="style1">pe:&nbsp;&quot;</span><span class="style2">text</span><span 
                class="style1">&quot;,</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;success:&nbsp;<span 
                class="style1">function</span>&nbsp;(data)&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;v<span style="color: black">ar&nbsp;oChar</span>t&nbsp;		=&nbsp;<span 
                style="background: yellow">&lt;%</span><span style="color: blue">=</span>chtSales.ClientID&nbsp;<span 
                style="background: yellow">%&gt;</span>;
&nbsp;<span style="color: blue">&nbsp;&nbsp;&nbsp;</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;oChart.xmlData&nbsp;&nbsp;&nbsp;	=&nbsp;data;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;oChart.chartType&nbsp;	=&nbsp;chartType;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;oChart.showChart();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;});
&nbsp;&nbsp;&nbsp;&nbsp;}
<span style="color: blue">&lt;/</span><span style="color: maroon">script</span><span 
                style="color: blue">&gt;</span></pre>
        
        </div>
        <div>
        
            <pre style="font-family: consolas">         Period:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue">&lt;</span><span style="color: maroon">select</span>&nbsp;<span 
                style="color: red">id</span><span style="color: blue">=&quot;period&quot;</span>&nbsp;<span 
                style="color: red">onchange</span><span style="color: blue">=&quot;loadChart()&quot;&gt;</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue">&lt;</span><span style="color: maroon">option</span>&nbsp;<span 
                style="color: red">value</span><span style="color: blue">=&quot;2010&quot;&gt;</span>2010<span 
                style="color: blue">&lt;/</span><span style="color: maroon">option</span><span 
                style="color: blue">&gt;</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue">&lt;</span><span style="color: maroon">option</span>&nbsp;<span 
                style="color: red">value</span><span style="color: blue">=&quot;2009&quot;&gt;</span>2009<span 
                style="color: blue">&lt;/</span><span style="color: maroon">option</span><span 
                style="color: blue">&gt;</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue">&lt;</span><span style="color: maroon">option</span>&nbsp;<span 
                style="color: red">value</span><span style="color: blue">=&quot;2008&quot;&gt;</span>2008<span 
                style="color: blue">&lt;/</span><span style="color: maroon">option</span><span 
                style="color: blue">&gt;</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue">&lt;/</span><span style="color: maroon">select</span><span 
                style="color: blue">&gt;</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Type:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue">&lt;</span><span style="color: maroon">select</span>&nbsp;<span 
                style="color: red">id</span><span style="color: blue">=&quot;chartType&quot;</span>&nbsp;<span 
                style="color: red">onchange</span><span style="color: blue">=&quot;loadChart()&quot;&gt;</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue">&lt;</span><span style="color: maroon">option</span>&nbsp;<span 
                style="color: red">value</span><span style="color: blue">=&quot;Area2DChart&quot;&gt;</span>Area&nbsp;2D&nbsp;Chart<span 
                style="color: blue">&lt;/</span><span style="color: maroon">option</span><span 
                style="color: blue">&gt;</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue">&lt;</span><span style="color: maroon">option</span>&nbsp;<span 
                style="color: red">value</span><span style="color: blue">=&quot;Bar2DChart&quot;&gt;</span>Bar&nbsp;2D&nbsp;Chart<span 
                style="color: blue">&lt;/</span><span style="color: maroon">option</span><span 
                style="color: blue">&gt;</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue">&lt;</span><span style="color: maroon">option</span>&nbsp;<span 
                style="color: red">value</span><span style="color: blue">=&quot;Column2DChart&quot;&gt;</span>Column&nbsp;2D&nbsp;Chart<span 
                style="color: blue">&lt;/</span><span style="color: maroon">option</span><span 
                style="color: blue">&gt;</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue">&lt;</span><span style="color: maroon">option</span>&nbsp;<span 
                style="color: red">value</span><span style="color: blue">=&quot;Column3DChart&quot;&gt;</span>Column&nbsp;3D&nbsp;Chart<span 
                style="color: blue">&lt;/</span><span style="color: maroon">option</span><span 
                style="color: blue">&gt;</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue">&lt;</span><span style="color: maroon">option</span>&nbsp;<span 
                style="color: red">value</span><span style="color: blue">=&quot;LineChart&quot;&gt;</span>Line&nbsp;Chart<span 
                style="color: blue">&lt;/</span><span style="color: maroon">option</span><span 
                style="color: blue">&gt;</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue">&lt;/</span><span style="color: maroon">select</span><span 
                style="color: blue">&gt;</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Template:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue">&lt;</span><span style="color: maroon">select</span>&nbsp;<span 
                style="color: red">id</span><span style="color: blue">=&quot;chartTemplate&quot;</span>&nbsp;<span 
                style="color: red">onchange</span><span style="color: blue">=&quot;loadChart()&quot;&gt;</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue">&lt;</span><span style="color: maroon">option</span>&nbsp;<span 
                style="color: red">value</span><span style="color: blue">=&quot;OfficeTemplate&quot;&gt;</span>Office<span 
                style="color: blue">&lt;/</span><span style="color: maroon">option</span><span 
                style="color: blue">&gt;</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue">&lt;</span><span style="color: maroon">option</span>&nbsp;<span 
                style="color: red">value</span><span style="color: blue">=&quot;OfficeLightTemplate&quot;&gt;</span>Office&nbsp;Light<span 
                style="color: blue">&lt;/</span><span style="color: maroon">option</span><span 
                style="color: blue">&gt;</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue">&lt;</span><span style="color: maroon">option</span>&nbsp;<span 
                style="color: red">value</span><span style="color: blue">=&quot;OfficeDarkTemplate&quot;&gt;</span>Office&nbsp;Dark<span 
                style="color: blue">&lt;/</span><span style="color: maroon">option</span><span 
                style="color: blue">&gt;</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue">&lt;</span><span style="color: maroon">option</span>&nbsp;<span 
                style="color: red">value</span><span style="color: blue">=&quot;OceanTemplate&quot;&gt;</span>Ocean<span 
                style="color: blue">&lt;/</span><span style="color: maroon">option</span><span 
                style="color: blue">&gt;</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue">&lt;/</span><span style="color: maroon">select</span><span 
                style="color: blue">&gt;</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue">&lt;</span><span style="color: maroon">hr</span>&nbsp;<span 
                style="color: blue">/&gt;</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue">&lt;</span><span style="color: maroon">fcl</span><span 
                style="color: blue">:</span><span style="color: maroon">FChart</span>&nbsp;<span 
                style="color: red">ID</span><span style="color: blue">=&quot;chtSales&quot;</span>&nbsp;<span 
                style="color: red">runat</span><span style="color: blue">=&quot;server&quot;</span>&nbsp;<span 
                style="color: red">Width</span><span style="color: blue">=&quot;500&quot;</span>&nbsp;<span 
                style="color: red">Height</span><span style="color: blue">=&quot;320&quot;</span>&nbsp;<span 
                style="color: blue">/&gt;</span></pre>
        
        </div>
        <br />
        <br />
        In the CS code we simply hand all requests and, by using a switch, we define the chart selected.
        <div>
        
            <pre style="font-family: consolas"><span style="color: blue">protected</span>&nbsp;<span 
                style="color: blue">void</span>&nbsp;Page_Load(<span style="color: blue">object</span>&nbsp;sender,&nbsp;<span 
                style="color: #2b91af">EventArgs</span>&nbsp;e)
{
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue">if</span>&nbsp;(Request[<span style="color: #a31515">&quot;chartType&quot;</span>]&nbsp;!=&nbsp;<span 
                style="color: blue">null</span>)
&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue">string</span>&nbsp;xmlData&nbsp;=&nbsp;GetSalesChart(
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Request[<span style="color: #a31515">&quot;period&quot;</span>].ToString(),
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Request[<span style="color: #a31515">&quot;chartType&quot;</span>].ToString(),
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Request[<span style="color: #a31515">&quot;chartTemplate&quot;</span>].ToString()
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;).ToXML();
 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: green">//loaded&nbsp;by&nbsp;ajax</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Response.Clear();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Response.ClearContent();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Response.ContentType&nbsp;=&nbsp;<span style="color: #a31515">&quot;text/xml&quot;</span>;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Response.Write(xmlData);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Response.End();
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue">else</span>
&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: green">//default.</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;chtSales.ShowChart(GetSalesChart(<span style="color: #a31515">&quot;2010&quot;</span>,&nbsp;<span 
                style="color: #a31515">&quot;Area2DChart&quot;</span>,&nbsp;<span style="color: #a31515">&quot;OfficeTemplate&quot;</span>));
&nbsp;&nbsp;&nbsp;&nbsp;}
}
 
<span style="color: blue">public</span>&nbsp;<span style="color: #2b91af">SingleSeriesChart</span>&nbsp;GetSalesChart(<span 
                style="color: blue">string</span>&nbsp;period,&nbsp;<span style="color: blue">string</span>&nbsp;chartType,&nbsp;<span 
                style="color: blue">string</span>&nbsp;chartTemplate)
{
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #2b91af">SingleSeriesChart</span>&nbsp;oChart;
 
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue">switch</span>&nbsp;(chartType)
&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue">case</span>&nbsp;<span style="color: #a31515">&quot;Area2DChart&quot;</span>:&nbsp;oChart&nbsp;=&nbsp;<span 
                style="color: blue">new</span>&nbsp;<span style="color: #2b91af">Area2DChart</span>();&nbsp;<span 
                style="color: blue">break</span>;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue">case</span>&nbsp;<span style="color: #a31515">&quot;Bar2DChart&quot;</span>:&nbsp;oChart&nbsp;=&nbsp;<span 
                style="color: blue">new</span>&nbsp;<span style="color: #2b91af">Bar2DChart</span>();&nbsp;<span 
                style="color: blue">break</span>;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue">case</span>&nbsp;<span style="color: #a31515">&quot;Column2DChart&quot;</span>:&nbsp;oChart&nbsp;=&nbsp;<span 
                style="color: blue">new</span>&nbsp;<span style="color: #2b91af">Column2DChart</span>();&nbsp;<span 
                style="color: blue">break</span>;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue">case</span>&nbsp;<span style="color: #a31515">&quot;Column3DChart&quot;</span>:&nbsp;oChart&nbsp;=&nbsp;<span 
                style="color: blue">new</span>&nbsp;<span style="color: #2b91af">Column3DChart</span>();&nbsp;<span 
                style="color: blue">break</span>;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue">case</span>&nbsp;<span style="color: #a31515">&quot;LineChart&quot;</span>:&nbsp;oChart&nbsp;=&nbsp;<span 
                style="color: blue">new</span>&nbsp;<span style="color: #2b91af">LineChart</span>();&nbsp;<span 
                style="color: blue">break</span>;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue">default</span>:&nbsp;<span style="color: blue">throw</span>&nbsp;<span 
                style="color: blue">new</span>&nbsp;<span style="color: #2b91af">Exception</span>(<span 
                style="color: #a31515">&quot;chart&nbsp;type&nbsp;not&nbsp;expected.&quot;</span>);
&nbsp;&nbsp;&nbsp;&nbsp;}
 
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue">switch</span>&nbsp;(chartTemplate)
&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue">case</span>&nbsp;<span style="color: #a31515">&quot;OfficeTemplate&quot;</span>:&nbsp;oChart.Template&nbsp;=&nbsp;<span 
                style="color: blue">new</span>&nbsp;<span style="color: #2b91af">OfficeTemplate</span>();&nbsp;<span 
                style="color: blue">break</span>;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue">case</span>&nbsp;<span style="color: #a31515">&quot;OfficeLightTemplate&quot;</span>:&nbsp;oChart.Template&nbsp;=&nbsp;<span 
                style="color: blue">new</span>&nbsp;<span style="color: #2b91af">OfficeLightTemplate</span>();&nbsp;<span 
                style="color: blue">break</span>;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue">case</span>&nbsp;<span style="color: #a31515">&quot;OfficeDarkTemplate&quot;</span>:&nbsp;oChart.Template&nbsp;=&nbsp;<span 
                style="color: blue">new</span>&nbsp;<span style="color: #2b91af">OfficeDarkTemplate</span>();&nbsp;<span 
                style="color: blue">break</span>;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue">case</span>&nbsp;<span style="color: #a31515">&quot;OceanTemplate&quot;</span>:&nbsp;oChart.Template&nbsp;=&nbsp;<span 
                style="color: blue">new</span>&nbsp;<span style="color: #2b91af">OceanTemplate</span>();&nbsp;<span 
                style="color: blue">break</span>;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue">default</span>:&nbsp;<span style="color: blue">throw</span>&nbsp;<span 
                style="color: blue">new</span>&nbsp;<span style="color: #2b91af">Exception</span>(<span 
                style="color: #a31515">&quot;chart&nbsp;template&nbsp;not&nbsp;expected.&quot;</span>);
&nbsp;&nbsp;&nbsp;&nbsp;}
 
&nbsp;&nbsp;&nbsp;&nbsp;oChart.ChartTitles.Caption&nbsp;=&nbsp;<span style="color: #a31515">&quot;Anual&nbsp;Sales&quot;</span>;
&nbsp;&nbsp;&nbsp;&nbsp;oChart.ChartTitles.SubCaption&nbsp;=&nbsp;<span style="color: #a31515">&quot;Period&nbsp;2010&quot;</span>;
 
&nbsp;&nbsp;&nbsp;&nbsp;oChart.DataSource&nbsp;=&nbsp;GetData(period).ToList();
&nbsp;&nbsp;&nbsp;&nbsp;oChart.DataTextField&nbsp;=&nbsp;<span style="color: #a31515">&quot;Month&quot;</span>;
&nbsp;&nbsp;&nbsp;&nbsp;oChart.DataValueField&nbsp;=&nbsp;<span style="color: #a31515">&quot;Total&quot;</span>;
 
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue">return</span>&nbsp;oChart;
}
</pre>
        
        </div>
    </div>
    </form>
</body>
</html>
